/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.vale.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Entity
@Table(name = "contact_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ContactType.findAll", query = "SELECT c FROM ContactType c"),
    @NamedQuery(name = "ContactType.findByCodcontacttype", query = "SELECT c FROM ContactType c WHERE c.codcontacttype = :codcontacttype"),
    @NamedQuery(name = "ContactType.findByDesctype", query = "SELECT c FROM ContactType c WHERE c.desctype = :desctype")})
public class ContactType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "codcontacttype")
    private Integer codcontacttype;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "desctype")
    private String desctype;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codcontacttype")
    private List<ContactSite> contactSiteList;

    public ContactType() {
    }

    public ContactType(Integer codcontacttype) {
        this.codcontacttype = codcontacttype;
    }

    public ContactType(Integer codcontacttype, String desctype) {
        this.codcontacttype = codcontacttype;
        this.desctype = desctype;
    }

    public Integer getCodcontacttype() {
        return codcontacttype;
    }

    public void setCodcontacttype(Integer codcontacttype) {
        this.codcontacttype = codcontacttype;
    }

    public String getDesctype() {
        return desctype;
    }

    public void setDesctype(String desctype) {
        this.desctype = desctype;
    }

    @XmlTransient
    public List<ContactSite> getContactSiteList() {
        return contactSiteList;
    }

    public void setContactSiteList(List<ContactSite> contactSiteList) {
        this.contactSiteList = contactSiteList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codcontacttype != null ? codcontacttype.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContactType)) {
            return false;
        }
        ContactType other = (ContactType) object;
        if ((this.codcontacttype == null && other.codcontacttype != null) || (this.codcontacttype != null && !this.codcontacttype.equals(other.codcontacttype))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.vale.entity.ContactType[ codcontacttype=" + codcontacttype + " ]";
    }
    
}
